﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using System.Web.Security;
using VacationsRequest.Models;
using System.Web.Profile;
using ReportManagement;

namespace VacationsRequest.Controllers
{


    /// <summary>
    /// Extends the controller with functionality for rendering PDF views
    /// </summary>
    public class ReportsController : PdfViewController
    {
        private EmployeeDBContext db = new EmployeeDBContext();
        private VacationApprovalDBContext dbApprovals = new VacationApprovalDBContext();
        private HtmlViewRenderer htmlViewRenderer = new HtmlViewRenderer();
        private StandardPdfRenderer standardPdfRenderer = new StandardPdfRenderer();
        private TeamDBContext dbTeams = new TeamDBContext();

        public ActionResult PrintVacationsForm(int id, string requestId)
        {
            Employee emp = db.Employees.Find(id);
            VacationApproval vap = dbApprovals.VacationApproval.Find(new Guid(requestId));
            VacationsForm vf = new VacationsForm();

            vf.FullName = emp.FirstName + " " + emp.FirstLastName + " " + emp.SecondLastName;
            vf.Ident = emp.Ced;
            vf.Project = (from u in dbTeams.Teams
                                where u.ID == emp.IdTeam
                                select u.Name).First();
            vf.Inicio = vap.FromDate.ToString("dd/MM/yyyy");
            vf.Fin = vap.ToDate.ToString("dd/MM/yyyy");
            vf.Totales = vap.NumDays.ToString();

            return this.ViewPdf("Formulario de verificación vacaciones", "PrintVacationsForm", vf);
        }

      
    }

    public class VacationsForm
    {
        public string FullName { get; set; }
        public string Ident { get; set; }
        public string Project { get; set; }
        public string Inicio { get; set; }
        public string Fin { get; set; }
        public string Totales { get; set; }
    }
}